#include "./../Include/public.h"
void add_stu()
{
	printf("输入学生信息：\n");
	printf("学号 姓名 所选课程(默认为0) 总学分(默认为0)\n");
	struct stu* node = (struct stu*)malloc(sizeof(struct stu));
	scanf("%s %s %d %d",node->sno,node->name,&node->courses[0],&node->sum);
	FILE *f;
 	f = fopen("./data/log.log", "a+");
       time_t now ;
       struct tm *tm_now ;
       time(&now) ;
       tm_now = localtime(&now) ;
  		fprintf(f,"datetime: %d-%d-%d %d:%d:%d\n",tm_now->tm_year+1900, tm_now->tm_mon+1, tm_now->tm_mday, tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec) ;
  	fprintf(f, "add student: %s\n",node->sno);
  	fclose(f);
	
	if (head_stu == NULL) {
		head_stu = node;
	} else {
		struct stu *p = head_stu;
		struct stu *q = p;
		while (p != NULL) {
			if (!strcmp(p->sno,node->sno)) {
				printf("学生已存在！\n");
				return ;
			}
			q = p;	
			p = p->next;
		}
		q->next = node;
		node->next = NULL; 
	}
	 
}
